<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title></title>
  </head>
  <body>
      <script type="text/javascript">
  console.log("=======return 函数调用========");
     function add(x,y) {
        return x+y;
        console.log("返回后面的代码");
     }
     console.log(add(2,3));
     console.log("======递归====");
  function fib(num) {
    if(num > 2){
      return fib(num - 2)+fib(num - 1);
    }else{
      return 1;
    }
  }
    console.log(fib(6));
    console.log("=======凡是可以使用值得地方，就能使用函数========");
    var option = add;
        console.log(option(5,6));
    function a(op){
          return op;
        }
        a(add(8,9));
        console.log(a(add(8,9)));
        var b ={
          name :add,
        }
        console.log(b.name(5,6));
    console.log("=======name属性========");
    console.log("=======name属性返回紧跟在function关键字之后的那个函数名========");
    console.log("=======f1========");
    function f1() {
    }
    console .log(f1.name);
    var f2 =function () {

    }
    console.log("=======f2========");
      console .log(f2.name);

      console.log("=======length属性========");
      console.log("=======length属性返回函数预期传入的参数个数，即函数定义之中的参数个数========");
      function f3(a,b,c,d) {

      }
      console.log(f3.length);
      console.log("=======函数的toString方法返回函数的源码========");
      function f4() {
        a();
        b();
        c();
        d();
      }
      console.log(f4.toString());
      console.log("=======利用这一点，可以变相实现多行字符串========");
      var f5 =function (val) {
           var arr = val.toString().split('\n');
           return arr.slice(1,arr.length-1).join('\n');
      }
      function f6() {

      }
      console.log(f5(f6.toString()));
      console.log("=======全局变量：在函数外申明的变量========");
      console.log("=======局部变量：在函数内申明的变量========");
      var name = "debang";
      function f7() {
        return name;
      }
      function f8() {
        var age = 18;
        return name + "is good ,this age is"+age;

      }
      console.log(f7());
      console.log(f8());
      console.log(f7()+f8());
    </script>
  </body>
</html>
